<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //转化为数值型
        var tt1 ='1';
        var tt2 ='2.123';
        //parseInt()只能转化为整数
        console.log(parseInt(tt1));//1
        console.log(parseInt(tt2));//2
        //parseFloat()能转化小数
        console.log(parseFloat(tt1));//1
        console.log(parseFloat(tt2));//2.123
        //Number()  强制转换，小数也能
        console.log(Number(tt2));//1
        console.log(Number(tt2));//2.123
        //js 隐式转换
        console.log(+tt2);//2.123
        console.log(tt2-0);//2.123
    </script>
</body>
</html>